package com.blue.ocean.hole.async;

import java.time.Duration;
import java.util.concurrent.Executor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.task.TaskExecutionProperties;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class TaskConfiguration {


//    @Bean(name ="async1")
//    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
//        TaskExecutorBuilder builder = new TaskExecutorBuilder();
//        builder = builder.queueCapacity(50);
//        builder = builder.corePoolSize(5);
//        builder = builder.maxPoolSize(100);
//        builder = builder.allowCoreThreadTimeOut(true);
//        builder = builder.keepAlive(Duration.ofSeconds(2000));
//        builder = builder.threadNamePrefix("config-async1-thread-");
//        return builder.build();
//    }
//
//    @Bean(name ="async2")
//    public ThreadPoolTaskExecutor threadPoolTaskExecutor1() {
//        TaskExecutorBuilder builder = new TaskExecutorBuilder();
//        builder = builder.queueCapacity(50);
//        builder = builder.corePoolSize(5);
//        builder = builder.maxPoolSize(100);
//        builder = builder.allowCoreThreadTimeOut(true);
//        builder = builder.keepAlive(Duration.ofSeconds(2000));
//        builder = builder.threadNamePrefix("config-async2-thread-");
//        return builder.build();
//    }
}
